From: Sven Eckelmann Date: Fri, 5 Sep 2025 14:19:21 +0000 (+0200) Subject: batctl: Merge bugfixes from 2025.3 X-Git-Url: http://git.openwrt.org/%22https:/collectd.org//%22http:/www.crowdsec.net/%22/%22https:/collectd.org/%22http:/www.crowdsec.net/%22?a=commitdiff_plain;h=refs%2Fpull%2F1139%2Fhead;p=feed%2Frouting.git batctl: Merge bugfixes from 2025.3 * event: Fix direct parsing on hardif for set_hardif * avoid memory leak in print_routing_algos Signed-off-by: Sven Eckelmann --- diff --git a/batctl/Makefile b/batctl/Makefile index daee9dc..33843e1 100644 --- a/batctl/Makefile +++ b/batctl/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=batctl PKG_VERSION:=2024.3 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://downloads.open-mesh.org/batman/releases/batman-adv-$(PKG_VERSION) diff --git a/batctl/patches/0001-batctl-event-Fix-direct-parsing-on-hardif-for-set_ha.patch b/batctl/patches/0001-batctl-event-Fix-direct-parsing-on-hardif-for-set_ha.patch new file mode 100644 index 0000000..218296a --- /dev/null +++ b/batctl/patches/0001-batctl-event-Fix-direct-parsing-on-hardif-for-set_ha.patch @@ -0,0 +1,27 @@ +From: Sven Eckelmann +Date: Sun, 3 Aug 2025 08:48:40 +0200 +Subject: batctl: event: Fix direct parsing on hardif for set_hardif + +The code to get the hard interface name for an even was accidentally +checking for BATADV_ATTR_MESH_IFNAME instead of BATADV_ATTR_HARD_IFNAME. As +result, the fallback code was always used when BATADV_ATTR_MESH_IFNAME +would have not been available. + +Luckily, at the moment, BATADV_ATTR_HARD_IFNAME is always available when +BATADV_ATTR_MESH_IFNAME is set BATADV_CMD_SET_HARDIF events. + +Fixes: d12322eeb361 ("batctl: event: Get ifname from netlink message") +Signed-off-by: Sven Eckelmann +Origin: upstream, https://git.open-mesh.org/batctl.git/commit/?id=03288f4f3060591dbc33600b4e5f6371d6a9f4ff + +--- a/event.c ++++ b/event.c +@@ -320,7 +320,7 @@ static void event_parse_set_hardif(struc + return; + } + +- if (attrs[BATADV_ATTR_MESH_IFNAME]) { ++ if (attrs[BATADV_ATTR_HARD_IFNAME]) { + hardif_name = nla_get_string(attrs[BATADV_ATTR_HARD_IFNAME]); + } else { + /* compatibility for Linux < 5.14/batman-adv < 2021.2 */ diff --git a/batctl/patches/0002-batctl-Avoid-memory-leak-in-print_routing_algos.patch b/batctl/patches/0002-batctl-Avoid-memory-leak-in-print_routing_algos.patch new file mode 100644 index 0000000..904093f --- /dev/null +++ b/batctl/patches/0002-batctl-Avoid-memory-leak-in-print_routing_algos.patch @@ -0,0 +1,31 @@ +From: Sven Eckelmann +Date: Sun, 3 Aug 2025 08:49:12 +0200 +Subject: batctl: Avoid memory leak in print_routing_algos + +The opts.remaining_header string is alocated before the netlink callback +object is created. But the callback object allocation can fail and the +function will return in this case. To fix this, either the string buffer +must be freed in this case or the opts.remaining_header allocation can +simply be moved to a later point. + +Fixes: 0a14f8800dac ("batctl: Handle nl_cb_alloc errors") +Signed-off-by: Sven Eckelmann +Origin: upstream, https://git.open-mesh.org/batctl.git/commit/?id=9363370cee11af3687ebef028f7c4518107ea424 + +--- a/routing_algo.c ++++ b/routing_algo.c +@@ -96,12 +96,12 @@ static int print_routing_algos(struct st + nl_send_auto_complete(state->sock, msg); + nlmsg_free(msg); + +- opts.remaining_header = strdup("Available routing algorithms:\n"); +- + cb = nl_cb_alloc(NL_CB_DEFAULT); + if (!cb) + return -ENOMEM; + ++ opts.remaining_header = strdup("Available routing algorithms:\n"); ++ + nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, netlink_print_common_cb, + &opts); + nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, netlink_stop_callback, NULL);